import {
    baseUrl
} from './config.js';

export function topList() {
    return uni.request({
        url: `${baseUrl}/toplist/detail`,
        method: 'GET'
    }).catch(error => {
        console.error('获取榜单详情失败:', error);
        return Promise.reject(error);
    });
}

export function listDetail(listId) {
    return uni.request({
        url: `${baseUrl}/playlist/detail?id=${listId}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取歌单详情失败:', error);
        return Promise.reject(error);
    });
}

export function songDetail(id) {
    return uni.request({
        url: `${baseUrl}/song/detail?ids=${id}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取歌曲详情失败:', error);
        return Promise.reject(error);
    });
}

export function songUrl(id) {
    return uni.request({
        url: `${baseUrl}/song/url?id=${id}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取歌曲播放地址失败:', error);
        return Promise.reject(error);
    });
}

export function songLyric(id) {
    return uni.request({
        url: `${baseUrl}/lyric?id=${id}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取歌曲歌词失败:', error);
        return Promise.reject(error);
    });
}

export function simiSong(id) {
    return uni.request({
        url: `${baseUrl}/simi/song?id=${id}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取相似歌曲失败:', error);
        return Promise.reject(error);
    });
}

export function commentMusic(id) {
    return uni.request({
        url: `${baseUrl}/comment/music?id=${id}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取歌曲评论失败:', error);
        return Promise.reject(error);
    });
}

export function searhHotDetail() {
    return uni.request({
        url: `${baseUrl}/search/hot/detail`,
        method: 'GET'
    }).catch(error => {
        console.error('获取热搜详情失败:', error);
        return Promise.reject(error);
    });
}

export function searchSuggest(keywords) {
    return uni.request({
        url: `${baseUrl}/search/suggest?keywords=${keywords}`,
        method: 'GET'
    }).catch(error => {
        console.error('获取搜索建议失败:', error);
        return Promise.reject(error);
    });
}

export function searchSongs(keyword) {
    return uni.request({
        url: `${baseUrl}/search?keywords=${keyword}`,
        method: 'GET'
    }).catch(error => {
        console.error('搜索歌曲失败:', error);
        return Promise.reject(error);
    });
}